//
//  ImagesViewController.m
//  RBIOSBase
//
//  Created by ren on 28/09/2017.
//  Copyright © 2017 bryan. All rights reserved.
//

#import "ImagesViewController.h"
#import "ImagesCollectionViewCell.h"

static NSString * const cellIdentifier = @"imagesCollectionViewCell";

@interface ImagesViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>

@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@property (nonatomic, strong) NSMutableArray *imageList;

@end

@implementation ImagesViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
	_imageList = [NSMutableArray array];
	[_imageList addObject:@"https://isparta.github.io/compare-webp/image/gif_webp/webp/1.webp"];
	[_imageList addObject:@"https://isparta.github.io/compare-webp/image/png_webp/webp_lossless/3.webp"];
	[_imageList addObject:@"https://isparta.github.io/compare-webp/image/png_webp/webp_lossless/7.webp"];
	[_imageList addObject:@"https://isparta.github.io/compare-webp/image/png_webp/webp_lossless/6.webp"];
	[_imageList addObject:@"http://img.dmall.com/20161112/498b09b7-274b-4435-881e-93d8c664d4de_240x240H.webp"];
	[_imageList addObject:@"http://static.17sucai.com/upload/32215/2013-11-22/4175c925a9b45e4f51993ec11156f0bb.jpg"];
	[_imageList addObject:@"http://www.sinaimg.cn/dy/slidenews/1_img/2017_27/63957_1285861_470607.jpg"];
	[_imageList addObject:@"http://img.ivsky.com/img/tupian/pre/201410/29/lantian_baiyun_yangguang-012.jpg"];
	
	[_imageList addObject:@"http://seopic.699pic.com/photo/40005/2408.jpg_wh1200.jpg"];
	[_imageList addObject:@"http://xqxtp.com/uploads/allimg/160828/43-160RQ04449-51.jpg"];
	
	
	
	[_imageList addObject:@"http://bestpricemoving.com/wordpress/wp-content/uploads/2012/03/wallcoo.com_beach_coconut_palm_51860.jpg"];
	[_imageList addObject:@"http://image5.tuku.cn/pic/wallpaper/fengjing/haibian/070.jpg"];
	[_imageList addObject:@"http://www.bradtguides.com/media/wysiwyg/destinations/africa/madagascar/beach_NosyBe_madagascar.jpg"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/Q3auHgzwzM4VvKOv6KiaWBNe1ibWZOhIdXibZglMicuTQUO4wQDWPBIBfA/132"];
	[_imageList addObject:@"https://www.traveltradecaribbean.com/wp-content/uploads/2016/11/caribbean.jpg"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/ver_1/bia7mZOmcRFMUXdoxJic3hTSfWO3nm1EmbVFPBnicAn2YTQ0T549ibriaZ2XhcPwFqko23Ua1rhxqmL63LUTh0mwgQzJmdKylv7R6GmgVCjHpLf4/132"];
	[_imageList addObject:@"http://img06.tooopen.com/images/20160913/tooopen_sy_178737377255.jpg"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/ver_1/nDyQHDK259ORsrUqmXhvPkqlYR9sLBpmjabLqnXTFVWdicwVCicIHW9uVZDqaceazEusaM9xycibpkvicticGD0T2MP4Gk492oZLoIxCfTbjjE0o/132"];
	
	[_imageList addObject:@"http://img1.3lian.com/2015/a1/112/d/79.jpg"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/ver_1/uiceuFw3LHeSJSfgOXIsf1G47miaLjrgfk3C7VItVmpdX7CRRn5FlU0AjVicfTuxhVyf0hxRPkC92NG9aMdYK4FRic9CeelpRGp9qfdr8iagW7c4/132"];
	
	
	
	
	
	[_imageList addObject:@"http://p4.music.126.net/FZut2i8IHktqqqr5ts6G4Q==/109951162847364388.jpg?param=120y120"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/ver_1/bI1ezaHJ2eibyOdLHZ2YTNVIn1YeMBGYafN4seTxAhghwcCVzL5FWho2dlSIJRKpv53k4jVJA9vYdzPM7hOgC34avEOlq0PzsnaUAlvGqVlU/132"];
	[_imageList addObject:@"http://www.51pptmoban.com/d/file/2016/04/07/540340a59e113f9392091501461b4860.jpg"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/Q3auHgzwzM4VvKOv6KiaWBNe1ibWZOhIdXibZglMicuTQUO4wQDWPBIBfA/132"];
	[_imageList addObject:@"http://images.china.cn/attachement/jpg/site1000/20170511/6c0b840a23ae1a7dfd3f03.jpg"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/ver_1/bia7mZOmcRFMUXdoxJic3hTSfWO3nm1EmbVFPBnicAn2YTQ0T549ibriaZ2XhcPwFqko23Ua1rhxqmL63LUTh0mwgQzJmdKylv7R6GmgVCjHpLf4/132"];
	[_imageList addObject:@"http://beautiful-images.org/wp-content/uploads/2016/03/Beautiful-Flowers.jpg"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/ver_1/nDyQHDK259ORsrUqmXhvPkqlYR9sLBpmjabLqnXTFVWdicwVCicIHW9uVZDqaceazEusaM9xycibpkvicticGD0T2MP4Gk492oZLoIxCfTbjjE0o/132"];
	
	[_imageList addObject:@"http://himg2.huanqiu.com/attachment2010/2017/0925/08/30/20170925083050425.jpg"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/ver_1/uiceuFw3LHeSJSfgOXIsf1G47miaLjrgfk3C7VItVmpdX7CRRn5FlU0AjVicfTuxhVyf0hxRPkC92NG9aMdYK4FRic9CeelpRGp9qfdr8iagW7c4/132"];
	
	
	
	
	[_imageList addObject:@"http://p4.music.126.net/FZut2i8IHktqqqr5ts6G4Q==/109951162847364388.jpg?param=120y120"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/ver_1/bI1ezaHJ2eibyOdLHZ2YTNVIn1YeMBGYafN4seTxAhghwcCVzL5FWho2dlSIJRKpv53k4jVJA9vYdzPM7hOgC34avEOlq0PzsnaUAlvGqVlU/132"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/ver_1/UW6iaZSPbTrCmp933mxTjWRwyDz87HySXDbwxoABecuabT1iaFYU3ZwiappxPFabj9RJtq4gGn4rnNByjTWsuj8sHTE0Mqcen5EACCiciaxotChc/132"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/Q3auHgzwzM4VvKOv6KiaWBNe1ibWZOhIdXibZglMicuTQUO4wQDWPBIBfA/132"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/ver_1/6ujZnsibBZT1MF34WebgSDCuiaDlyp123l7dFoMfkVXS89hYQIuL0sDefchMkrWSbHF7yicqvz6avpugdPplCkuB6DTl44TyZwichbGibgCBF74k/132"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/ver_1/bia7mZOmcRFMUXdoxJic3hTSfWO3nm1EmbVFPBnicAn2YTQ0T549ibriaZ2XhcPwFqko23Ua1rhxqmL63LUTh0mwgQzJmdKylv7R6GmgVCjHpLf4/132"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/Q3auHgzwzM79Xwibmw3LH8pBqE9jbO4IaNdXRINibxgQwsKxjbzFYQaw/132"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/ver_1/nDyQHDK259ORsrUqmXhvPkqlYR9sLBpmjabLqnXTFVWdicwVCicIHW9uVZDqaceazEusaM9xycibpkvicticGD0T2MP4Gk492oZLoIxCfTbjjE0o/132"];
	
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/ver_1/pGSP9o0NVNJUQibDjJjVOzKeBqHSO4XTKn8r12eR2ork3UGR4NEQNbLn1NMrOvIXkN2sOYT5iapdlZibxjicn1ZNn1zRww3oeqjCuvPnll1XqQQ/132"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/ver_1/uiceuFw3LHeSJSfgOXIsf1G47miaLjrgfk3C7VItVmpdX7CRRn5FlU0AjVicfTuxhVyf0hxRPkC92NG9aMdYK4FRic9CeelpRGp9qfdr8iagW7c4/132"];
	
	
	
	[_imageList addObject:@"http://p4.music.126.net/FZut2i8IHktqqqr5ts6G4Q==/109951162847364388.jpg?param=120y120"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/ver_1/bI1ezaHJ2eibyOdLHZ2YTNVIn1YeMBGYafN4seTxAhghwcCVzL5FWho2dlSIJRKpv53k4jVJA9vYdzPM7hOgC34avEOlq0PzsnaUAlvGqVlU/132"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/ver_1/UW6iaZSPbTrCmp933mxTjWRwyDz87HySXDbwxoABecuabT1iaFYU3ZwiappxPFabj9RJtq4gGn4rnNByjTWsuj8sHTE0Mqcen5EACCiciaxotChc/132"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/Q3auHgzwzM4VvKOv6KiaWBNe1ibWZOhIdXibZglMicuTQUO4wQDWPBIBfA/132"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/ver_1/6ujZnsibBZT1MF34WebgSDCuiaDlyp123l7dFoMfkVXS89hYQIuL0sDefchMkrWSbHF7yicqvz6avpugdPplCkuB6DTl44TyZwichbGibgCBF74k/132"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/ver_1/bia7mZOmcRFMUXdoxJic3hTSfWO3nm1EmbVFPBnicAn2YTQ0T549ibriaZ2XhcPwFqko23Ua1rhxqmL63LUTh0mwgQzJmdKylv7R6GmgVCjHpLf4/132"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/Q3auHgzwzM79Xwibmw3LH8pBqE9jbO4IaNdXRINibxgQwsKxjbzFYQaw/132"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/ver_1/nDyQHDK259ORsrUqmXhvPkqlYR9sLBpmjabLqnXTFVWdicwVCicIHW9uVZDqaceazEusaM9xycibpkvicticGD0T2MP4Gk492oZLoIxCfTbjjE0o/132"];
	
	
	
	[_imageList addObject:@"http://n.sinaimg.cn/news/20170927/x_sX-fymesmp1710897.jpg"];
	[_imageList addObject:@"http://img05.tooopen.com/images/20160121/tooopen_sy_155168162826.jpg"];
	
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/ver_1/pGSP9o0NVNJUQibDjJjVOzKeBqHSO4XTKn8r12eR2ork3UGR4NEQNbLn1NMrOvIXkN2sOYT5iapdlZibxjicn1ZNn1zRww3oeqjCuvPnll1XqQQ/132"];
	[_imageList addObject:@"http://wx.qlogo.cn/mmhead/ver_1/uiceuFw3LHeSJSfgOXIsf1G47miaLjrgfk3C7VItVmpdX7CRRn5FlU0AjVicfTuxhVyf0hxRPkC92NG9aMdYK4FRic9CeelpRGp9qfdr8iagW7c4/132"];
	
	
	UINib *nib = [UINib nibWithNibName:@"ImagesCollectionViewCell" bundle:[NSBundle mainBundle]];
	[self.collectionView registerNib:nib forCellWithReuseIdentifier:cellIdentifier];
//	[self.collectionView registerClass:[ImagesCollectionViewCell class] forCellWithReuseIdentifier:cellIdentifier];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - UICollectionViewDataSource

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
	return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
	return [self.imageList count];
}

- (__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
	ImagesCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
	if (!cell) {
		cell = [ImagesCollectionViewCell new];
	}
	cell.imageURL = [self.imageList objectAtIndex:indexPath.row];
	return cell;
}

#pragma mark - UICollectionViewDelegateFlowLayout

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
	return CGSizeMake(100, 100);
}

//- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
//{
//	return 30;
//}

#pragma mark - UICollectionViewDelegate

//- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section
//{
//	return UIEdgeInsetsMake(5, 5, 5, 0);
//}

@end
